public class Solution {
    public String convertToBase7(int num) {
        //直接调用Integer的toString()方法
        //Integer.toString(数字，转换成几进制);
        return Integer.toString(num, 7);
    }

//循环除7取模
    /*class Solution {
    public String convertToBase7(int num) {
        StringBuilder str=new StringBuilder();
        if(num==0){
            return "0";
        }

       if(num>0){
           while(num>0){

               int i=num%7;
               str.append(i);
               num=num/7;
           }
           return str.reverse().toString();
       }else{
            num=0-num;
           while(num>0){

               int i=num%7;
               str.append(i);
               num=num/7;
           }
           return "-"+str.reverse().toString();
       }

    }
}*/
}
